<template lang="">
    <div>
        <van-field v-model='form.username'/>
        <van-field v-model='form.password'/>
        <van-button @click='login'>登录</van-button>
    </div>
</template>
<script>
import axios from '../http/axios'
export default {
    data(){
        return{
            form:{}
        }
    },
    methods: {
        login(){
            axios('/login','post',this.form).then(res=>{
                localStorage.setItem('userid',res.userid)
                localStorage.setItem('is_admin',res.is_admin)
                localStorage.setItem('name',res.username)
                localStorage.setItem('token',res.token)
                let pagelist = res.pagelist
                if(pagelist.length>0){
                    pagelist=JSON.stringify(pagelist)
                }
                localStorage.setItem('pagelist',pagelist)
            })
        },
        test(){
            axios('/roleM','get').then(res=>{

            })
        }
        
    },
    mounted() {
    //    this.login()
        // this.test()
    },
}
</script>
<style lang="">
    
</style>